<template>
	<view>

		

		<!-- 手动添加弹窗 -->
		
			<form @submit="formSubmit" >
				<view class="addPop_box">
					<view class="handleList_box">
						<view class="handleList_con">
							<view class="handleLabel handleLabelLong">工友姓名：</view>
							<view class="handleList">
								<view class="pickerCon">
									<input name="name" v-model="userInfo.name" placeholder="请输入工友姓名"
										placeholder-class="placeholderColor">
								</view>
							</view>
						</view>
						<view class="handleList_con">
							<view class="handleLabel handleLabelLong">工友电话：</view>
							<view class="handleList">
								<view class="pickerCon">
									<input name="mobile" v-model="userInfo.mobile" placeholder="请输入工友电话"
										placeholder-class="placeholderColor">
								</view>
							</view>
						</view>
					</view>
					<view class="handlePost_con">
						<button class="completeBtn" form-type="submit" hover-class="none">保存</button>
					</view>
				</view>
			</form>

	</view>
</template>

<script>
	export default {
		data() {
			return {
				// 默认工地信息
				defaultWorksite: JSON.parse(uni.getStorageSync('defaultWorksite')),

				// 手动添加弹窗
				addShow: false,
				// 表单
				formData: {
					name: '',
					salary: '',
					overtime_salary: '',
				},
				id:'',
				userInfo:{},
			}
		},
		onLoad(e){
			this.id=e.id;
			this.getInfo();
		},
		onShow() {},
		methods: {
			getInfo() {
				var _this = this;
				_this.$u.get('/api/project.member/getDetail', {
					id: _this.id,
					
				}).then(res => {
					console.log(res);
					_this.userInfo=res.data.userInfo
				}).catch(res => {
					console.log(res);
				})
			},
			
			// 提交
			formSubmit(e) {
				// console.log(e);
				var _this = this;
				var formData = e.detail.value;

				if (!formData.name) {
					uni.showModal({
						content: '姓名不能为空',
						showCancel: false,
					})
					return;
				}
				_this.formData = formData;
				_this.$u.throttle(_this.submitForm, 3000);
			},

			// 提交接口
			submitForm() {
				var _this = this;
				_this.$u.post('/api/user.index/add_do', {
					id: _this.userInfo.id,
					name: _this.formData.name,
					mobile: _this.formData.mobile,
					
				}).then(res => {
					console.log(res);
					uni.showToast({
						title:'编辑成功'
					})
					setTimeout(function(){
						uni.navigateBack()
					})
				}).catch(res => {
					console.log(res);
				})
			},
			
			
			
			

		}
	}
</script>

<style>
	page {
		background-color: #fff;
	}
</style>
<style scoped lang="scss">
	/* 菜单 */
	.messageMenu_box {
		padding: 0 30rpx;
	}

	.menuItem {
		padding: 30rpx 0;
		border-bottom: 1rpx solid #eee;
		overflow: hidden;
		display: flex;
		justify-content: space-between;
		align-items: center;
	}

	.menuItem:last-child .menuCon {
		border-bottom: 0;
	}

	.menuItem image {
		width: 100rpx;
		height: 100rpx;
	}

	.menuCon {
		flex: 2;
		padding: 40rpx 0;
		margin-left: 20rpx;
		display: flex;
		justify-content: space-between;
		align-items: center;
	}

	.menuItem .menuTit {
		font-size: 32rpx;
		font-weight: bold;
		color: $uni-color;
	}

	.menuItem .menuDesc {
		font-size: 24rpx;
		color: $uni-color-text;
	}

	// 手动添加弹窗
	.addPop_box {
		padding: 0 30rpx;
	}

	.addPop_tit {
		padding: 40rpx 0;
		font-size: 32rpx;
		font-weight: bold;
		color: $uni-color;
		text-align: center;
		overflow: hidden;
	}

	.handleList_box {
		padding: 15rpx 0;
	}
	
	.handlePost_con {
		padding: 0 30rpx 0 0;
		border: 0;
		position: fixed;
		bottom: 50rpx;
		left: 0rpx;
	}
	.completeBtn{
		margin-left: 30rpx;
		flex: 1;
		
	}
	.completeBtn:last-child{
		margin-right: 0;
	}
	
	.pickerCon input{
		width: 350rpx;
	}
	.handleList_con .pickerCon {
		padding: 30rpx 30rpx;
	}
</style>
